package com.lg.concurrent.pool.thread_pool;

import lombok.Data;
import lombok.SneakyThrows;

import java.util.concurrent.TimeUnit;

@Data
public class Task  implements  Runnable , Comparable<Task> {

    private int value;

    public  Task() {}


    public  Task( int value) {
        this.value = value;
    }
    @SneakyThrows
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + " start");
        TimeUnit.SECONDS.sleep(2);
        System.out.println(value);
        System.out.println(Thread.currentThread().getName() + " end");
    }


    @Override
    public int compareTo(Task o) {

        if (this.value > o.value) {
            return -1;
        }

        return 1;
    }
}
